package com.management.dao;

import com.management.model.Menus;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
public interface MenusDao extends BaseMapper<Menus> {

    @Select("SELECT\n" +
            "DISTINCT dm.*\n" +
            "FROM dm_account_role_project dar JOIN\n" +
            "dm_role_menu drm ON dar.role_num=drm.role_id JOIN\n" +
            "dm_menus dm ON dm.menu_id=drm.menu_id WHERE dar.account_id=#{accountId}")
    List<Menus> selectMenusByAccountId(Integer accountId);

    @Select("SELECT\n" +
            "dm.*\n" +
            "FROM dm_menus dm JOIN\n" +
            "dm_role_menu drm ON dm.menu_id=drm.menu_id WHERE drm.role_id=#{roleNum}")
    List<Menus> getMenusByRoleNum(Integer roleNum);
}
